from datetime import datetime

from django.db import models
from users.models import UserProfile
from movieinfo.models import Movie

class UserFavorite(models.Model):
    user=models.ForeignKey(UserProfile,verbose_name='用户',on_delete=models.CASCADE)
    movie_id=models.IntegerField('电影id',default=0)
    add_time = models.DateTimeField('添加时间', default=datetime.now)

    class Meta:
        verbose_name='用户收藏'
        verbose_name_plural=verbose_name


class UserComments(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=models.CASCADE)
    movie=models.ForeignKey(Movie, verbose_name='电影', on_delete=models.CASCADE)
    comment=models.CharField('评论',max_length=200)
    add_time = models.DateTimeField("添加时间", default=datetime.now)

    class Meta:
        verbose_name='用户评论'
        verbose_name_plural=verbose_name


class UserRecommend(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=models.CASCADE)
    movie_id = models.CharField('数据id', max_length=200)
    add_time = models.DateTimeField('添加时间', default=datetime.now)

    class Meta:
        verbose_name='个人推荐'
        verbose_name_plural=verbose_name



class UserBrowse(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=models.CASCADE)
    movie_id = models.IntegerField('数据id', default=0)
    add_time = models.DateTimeField('添加时间', default=datetime.now)

    class Meta:
        verbose_name='历史浏览'
        verbose_name_plural=verbose_name


class UserRatings(models.Model):
    user = models.ForeignKey(UserProfile, verbose_name='用户', on_delete=models.CASCADE)
    movie=models.ForeignKey(Movie, verbose_name='电影', on_delete=models.CASCADE)
    ratings=models.FloatField('评分')
    add_time = models.DateTimeField('添加时间', default=datetime.now)

    class Meta:
        verbose_name='用户评分'
        verbose_name_plural=verbose_name